/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package io.sentry;

import io.sentry.protocol.SentryId;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * NoOpSpan
 *
 * @since 2021-06-02
 **/
public final class NoOpSpan implements ISpan {
    private static final NoOpSpan INSTANCE = new NoOpSpan();

    private NoOpSpan() {
    }

    public static NoOpSpan getInstance() {
        return INSTANCE;
    }

    @Override
    public @NotNull ISpan startChild(final @NotNull String operation) {
        return NoOpSpan.getInstance();
    }

    @Override
    public @NotNull ISpan startChild(
        final @NotNull String operation, final @Nullable String description) {
        return NoOpSpan.getInstance();
    }

    @Override
    public @NotNull SentryTraceHeader toSentryTrace() {
        return new SentryTraceHeader(SentryId.EMPTY_ID, SpanId.EMPTY_ID, false);
    }

    @Override
    public void finish() {
    }

    @Override
    public void finish(@Nullable SpanStatus status) {
    }

    @Override
    public void setOperation(@NotNull String operation) {
    }

    @Override
    public @NotNull String getOperation() {
        return "";
    }

    @Override
    public void setDescription(@Nullable String description) {
    }

    @Override
    public @Nullable String getDescription() {
        return null;
    }

    @Override
    public void setStatus(@Nullable SpanStatus status) {
    }

    @Override
    public @Nullable SpanStatus getStatus() {
        return null;
    }

    @Override
    public void setThrowable(@Nullable Throwable throwable) {
    }

    @Override
    public @Nullable Throwable getThrowable() {
        return null;
    }

    @Override
    public @NotNull SpanContext getSpanContext() {
        return new SpanContext(SentryId.EMPTY_ID, SpanId.EMPTY_ID, "op", null, null);
    }

    @Override
    public void setTag(@NotNull String key, @NotNull String value) {
    }

    @Override
    public @Nullable String getTag(@NotNull String key) {
        return null;
    }

    @Override
    public boolean isFinished() {
        return false;
    }
}
